def bubbleSort(numbers): 
    count = 0
    exchanges = True 
    passnum = len(numbers)-1 
    while passnum > 0 and exchanges: 
        exchanges = False 
        for i in range(passnum): 
            if numbers[i] > numbers[i+1]: 
                exchanges = True
                count += 1
                numbers[i],numbers[i+1] = numbers[i+1],numbers[i] 
        passnum = passnum -1 
    return count
    
# === DO NOT modify the code below ===
def main():
    a = [ eval(x) for x in input().split() ]
    print(bubbleSort(a))
    print(" ".join(map(str,a)))
    
if __name__ == '__main__':
    main()
# === DO NOT modify the code above ===

